package com.yss.sofa.report.engine;

import org.apache.commons.lang3.StringUtils;

public final class Const {
	//关键字
	public static final String[] KEY_WORD={
		"__main__",
		"main",
		"__form__",
		"form",
		"style",
		"__style__",
		"SYS_REPORT_CODE",
		"SYS_REPORT_NAME",
		"SYS_REPORT_USER_NAME",
		"SYS_REPORT_USER_ID",
		"PAGE_INDEX",
		"PAGE_COUNT",
		"ROW",
		"COL",
		"DATA",
		"VALUE",
		"DISPLAY",
		"CONSTS",
		"to10",
		"to26",
		"toCNY",
		"ins",
		"_"
	};
	public static final boolean is_KEY_WORD(String s){
		if(StringUtils.isEmpty(s)){
			return true;
		}
		if(s.toUpperCase().startsWith("SYS")){
			return true;
		}
		for(String key_word:KEY_WORD){
			if(key_word.equalsIgnoreCase(s)){
				return true;
			}
		}
		return false;
	}
	//模板sheet名称
	public static final String MAIN_META="__main__";
	public static final String MAIN="main";
	public static final String FORM_META="__form__";
	public static final String FORM="form";
	public static final String STYLE="style";
	public static final String STYLE_META="__style__";
	public static final String CUSTOM_UPDATE="__customupdate__";
	public static final String[] TEMPLATE_SHEET_NAMES={
       MAIN_META,
       MAIN,
       FORM_META,
       FORM ,
       STYLE,
       STYLE_META,
       CUSTOM_UPDATE
	};
	//系统内置参数
	public static final String SYS_PARAMS_REPORT_CODE="SYS_REPORT_CODE";
	public static final String SYS_PARAMS_REPORT_NAME="SYS_REPORT_NAME";
	public static final String SYS_PARAMS_USER_ID="SYS_USER_ID";
	public static final String SYS_PARAMS_USER_NAME="SYS_USER_NAME";
	public static final String[] SYS_PARAMS={
		"SYS_REPORT_CODE",
		"SYS_REPORT_NAME",
		"SYS_USER_ID",
		"SYS_USER_NAME"
	};
	public static final String name_SYS_PARAMS(String s){
		if(SYS_PARAMS_REPORT_CODE.equals(s)) return "报表编码";
		if(SYS_PARAMS_REPORT_NAME.equals(s)) return "报表名称";
		if(SYS_PARAMS_USER_ID.equals(s)) return "用户ID";
		if(SYS_PARAMS_USER_NAME.equals(s)) return "用户名称";
		return "无效的系统参数";
	}
	public static final boolean is_SYS_PARAMS(String s){
		for(String sys_param: SYS_PARAMS){
			if(sys_param.equalsIgnoreCase(s)){
				return true;
			}
		}
		return false;
	}
	//参数表单类型
	public static final int FORM_INPUT_TYPE_TEXT=0;
	public static final int FORM_INPUT_TYPE_DATE=1;
	public static final int FORM_INPUT_TYPE_NUMBER=2;
	public static final int FORM_INPUT_TYPE_URL_LIST=3;
	public static final int FORM_INPUT_TYPE_DATASET_LIST=4;
	public static final int FORM_INPUT_TYPE_URL_TREE=5;
	public static final int FORM_INPUT_TYPE_DATASET_TREE=6;
	public static final int FORM_INPUT_TYPE_LAZY_LIST=7;
	public static final int FORM_INPUT_TYPE_LAZY_TREE=8;
	public static final int FORM_INPUT_TYPE_PASSWORD=9;
	public static final int FORM_INPUT_TYPE_CHECKBOX=10;
	public static final int FORM_INPUT_TYPE_URL_TREE_SELECT=11;
	public static final int FORM_INPUT_TYPE_CUSTOM=-1;
	public static final String name_FORM_INPUT_TYPE(int i){
		switch (i) {
		case FORM_INPUT_TYPE_TEXT:return "文本框";
		case FORM_INPUT_TYPE_DATE:return "日期框";
		case FORM_INPUT_TYPE_NUMBER:return "数值框";
		case FORM_INPUT_TYPE_URL_LIST:return "URL下拉列表";
		case FORM_INPUT_TYPE_DATASET_LIST:return "数据集下拉列表";
		case FORM_INPUT_TYPE_URL_TREE:return "URL下拉树";
		case FORM_INPUT_TYPE_DATASET_TREE:return "数据集下拉树";
		case FORM_INPUT_TYPE_LAZY_LIST:return "延迟加载数据集下拉列表";
		case FORM_INPUT_TYPE_LAZY_TREE:return "延迟加载数据集下拉列树";
		case FORM_INPUT_TYPE_PASSWORD:return "密码框";
		case FORM_INPUT_TYPE_CHECKBOX:return "复选框";
		case FORM_INPUT_TYPE_CUSTOM:return "自定义表单";
		default:
			return "无效的表单类型";
		}
	}
	//参数数据类型
	public static final int PARAM_DATA_TYPE_STRING=1;
	public static final int PARAM_DATA_TYPE_INT=2;
	public static final int PARAM_DATA_TYPE_DOUBLE=3;
	public static final int PARAM_DATA_TYPE_DATE=4;
	public static final int PARAM_DATA_TYPE_BOOLEAN=5;
	public static final int PARAM_DATA_TYPE_STRING_ARRAY=11;
	public static final int PARAM_DATA_TYPE_INT_ARRAY=22;
	public static final int PARAM_DATA_TYPE_DOUBLE_ARRAY=33;
	public static final int PARAM_DATA_TYPE_DATE_ARRAY=44;
	public static final int PARAM_DATA_TYPE_BOOLEAN_ARRAY=55;
	public static final String name_PARAM_DATA_TYPE(int i){
		switch (i) {
		case PARAM_DATA_TYPE_STRING:return "字符串";
		case PARAM_DATA_TYPE_INT:return "整数";
		case PARAM_DATA_TYPE_DOUBLE:return "双精度";
		case PARAM_DATA_TYPE_DATE:return "日期";
		case PARAM_DATA_TYPE_BOOLEAN:return "布尔";
		case PARAM_DATA_TYPE_STRING_ARRAY:return "字符串[]";
		case PARAM_DATA_TYPE_INT_ARRAY:return "整数[]";
		case PARAM_DATA_TYPE_DOUBLE_ARRAY:return "双精度[]";
		case PARAM_DATA_TYPE_DATE_ARRAY:return "日期[]";
		case PARAM_DATA_TYPE_BOOLEAN_ARRAY:return "布尔[]";
		default:
			return "无效的参数数据类型";
		}
	}
	//模板单元格类型
	public static final int REPORT_CELL_TYPE_SIMPLE=0;
	public static final int REPORT_CELL_TYPE_STATIC=1;
	public static final int REPORT_CELL_TYPE_DATA=2;
	public static final int REPORT_CELL_TYPE_EXP=3;
	public static final int REPORT_CELL_TYPE_CHART=4;
	public static final int REPORT_CELL_TYPE_FORM=5;
	public static final int REPORT_CELL_TYPE_RESULT=6;
	public static final int REPORT_CELL_TYPE_FIELD=7;
	public static final int REPORT_CELL_TYPE_PARAM=11;
	public static final int REPORT_CELL_TYPE_SQL_DATASET=21;
	public static final int REPORT_CELL_TYPE_OSGI_DATASET=22;
	public static final int REPORT_CELL_TYPE_SCRIPT_DATASET=23;
	public static final int REPORT_CELL_TYPE_VIRTUAL_DATASET=24;
	public static final int REPORT_CELL_TYPE_STATIC_DATASET=25;
	public static final int REPORT_CELL_TYPE_HETEROGENEOUS_SQL_DATASET=26;
	public static final int REPORT_CELL_TYPE_COL_HEADER=31;
	public static final int REPORT_CELL_TYPE_ROW_HEADER=32;
	public static final int REPORT_CELL_TYPE_FLOATING=41;
	public static final String name_REPORT_CELL_TYPE(int i){
		switch (i) {
		case REPORT_CELL_TYPE_SIMPLE:return "简单单元格";
		case REPORT_CELL_TYPE_STATIC:return "静态单元格";
		case REPORT_CELL_TYPE_DATA:return "数据单元格";
		case REPORT_CELL_TYPE_EXP:return "公式单元格";
		case REPORT_CELL_TYPE_CHART:return "图形单元格";
		case REPORT_CELL_TYPE_FORM:return "表单单元格";
		case REPORT_CELL_TYPE_RESULT:return "结果（保留）单元格";
		case REPORT_CELL_TYPE_FIELD:return "字段单元格";
		case REPORT_CELL_TYPE_PARAM:return "参数单元格";
		case REPORT_CELL_TYPE_SQL_DATASET:return "SQL数据集单元格";
		case REPORT_CELL_TYPE_OSGI_DATASET:return "OSGI数据集单元格";
		case REPORT_CELL_TYPE_SCRIPT_DATASET:return "Script数据集单元格";
		case REPORT_CELL_TYPE_VIRTUAL_DATASET:return "虚拟数据集单元格";
		case REPORT_CELL_TYPE_STATIC_DATASET:return "静态数据集单元格";
		case REPORT_CELL_TYPE_HETEROGENEOUS_SQL_DATASET:return "多库数据集单元格";
		case REPORT_CELL_TYPE_COL_HEADER:return "列头单元格";
		case REPORT_CELL_TYPE_ROW_HEADER:return "行头单元格";
		case REPORT_CELL_TYPE_FLOATING:return "浮动单元格";
		default:
			return "无效的单元格类型";
		}
	}
	//模板单元格移动方向
	public static final int CELL_MOVE_INFER=-1;
	public static final int CELL_MOVE_ABS=0;
	public static final int CELL_MOVE_RIGHT=1;
	public static final int CELL_MOVE_BOTTOM=2;
	public static final String name_CELL_MOVE(int i){
		switch (i) {
		case CELL_MOVE_INFER: return "根据填充方式推断";
		case CELL_MOVE_ABS: return "保持不变";
		case CELL_MOVE_RIGHT: return "向右移动";
		case CELL_MOVE_BOTTOM: return "向下移动";
		default:
			return "无效的移动方向";
		}
	}
	//模板单元格填充方式
	public static final int CELL_EXTEND_NONE=0;
	public static final int CELL_EXTEND_RIGHT=1;
	public static final int CELL_EXTEND_BOTTOM=2;
	public static final int CELL_EXTEND_RIGHT_BOTTOM=12;
	public static final int CELL_EXTEND_BOTTOM_RIGHT=21;
	public static final String name_CELL_EXTEND(int i){
		switch (i) {
		case CELL_EXTEND_NONE: return "不扩展";
		case CELL_EXTEND_RIGHT: return "向右扩展";
		case CELL_EXTEND_BOTTOM: return "向下扩展";
		case CELL_EXTEND_RIGHT_BOTTOM: return "字段向右数据向下扩展";
		case CELL_EXTEND_BOTTOM_RIGHT: return "字段向下数据向右扩展";
		default:
			return "无效的扩展类型";
		}
	}
	//模板单元格数据类型
	public static final int CELL_DATA_TYPE_STRING=0;
	public static final int CELL_DATA_TYPE_INT=1;
	public static final int CELL_DATA_TYPE_DOUBLE=2;
	public static final int CELL_DATA_TYPE_DATE=3;
	public static final int CELL_DATA_TYPE_EXP=4;
	public static final int CELL_DATA_TYPE_IMG=5;//除了Chart还有Floating
	public static final int CELL_DATA_TYPE_FORM=6;
	public static final int CELL_DATA_TYPE_DYNAMIC_STRING=7;
	public static final String name_CELL_DATA_TYPE(int i){
		switch (i) {
		case CELL_DATA_TYPE_STRING:return "字符串";
		case CELL_DATA_TYPE_INT:return "整数";
		case CELL_DATA_TYPE_DOUBLE:return "双精度";
		case CELL_DATA_TYPE_DATE:return "日期";
		case CELL_DATA_TYPE_EXP:return "公式";
		case CELL_DATA_TYPE_IMG:return "图形";
		case CELL_DATA_TYPE_FORM:return "表单";
		case CELL_DATA_TYPE_DYNAMIC_STRING:return "动态字符串";
		default:
			return "无效的单元格数据类型";
		}
	}
	//通配符
	public static final String NONE="_";
	public static final boolean is_NONE(String s){
		return NONE.equalsIgnoreCase(s);
	}
	//导出文件类型
	public static final int FILE_TYPE_STUB=0;
	public static final int FILE_TYPE_TEXT=1;
	public static final int FILE_TYPE_EXCEL=2;
	public static final int FILE_TYPE_WORD=3;
	public static final int FILE_TYPE_PDF=4;
	public static final int FILE_TYPE_PNG=5;
	public static final int FILE_TYPE_CUSTOM=6;
	public static final int FILE_TYPE_CUSTOM_XML=60;
	public static final int FILE_TYPE_CUSTOM_EXCEL=61;
	public static final int FILE_TYPE_DBF=7;
	public static final int FILE_TYPE_EXCEL_2003=2003;
	public static final String suffix_FILE_TYPE(int i){
		switch (i) {
		case FILE_TYPE_STUB:return ".stub";
		case FILE_TYPE_EXCEL:return ".xlsx";
		case FILE_TYPE_TEXT:return ".txt";
		case FILE_TYPE_PDF:return ".pdf";
		case FILE_TYPE_WORD:return ".docx";
		case FILE_TYPE_PNG:return ".png";
		case FILE_TYPE_CUSTOM_XML:return ".xml";
		case FILE_TYPE_CUSTOM_EXCEL:return ".xlsx";
		case FILE_TYPE_DBF:return ".dbf";
		case FILE_TYPE_EXCEL_2003:return ".xls";
		default:
			return ".none";
		}
	}
	public static final String name_FILE_TYPE(int i){
		switch (i) {
		case FILE_TYPE_STUB:return "stub";
		case FILE_TYPE_EXCEL:return "excel";
		case FILE_TYPE_TEXT:return "text";
		case FILE_TYPE_PDF:return "pdf";
		case FILE_TYPE_WORD:return "word";
		case FILE_TYPE_PNG:return "png";
		case FILE_TYPE_CUSTOM_XML:return "xml";
		case FILE_TYPE_CUSTOM_EXCEL:return "excel";
		case FILE_TYPE_DBF:return "dbf";
		case FILE_TYPE_EXCEL_2003:return "excel03";
		default:
			return "";
		}
	}
	//数据库类型
	public static final int DB_OTHER=-1;
	public static final int DB_ORACLE=0;
	public static final int DB_MYSQL=1;
	public static final int DB_DB2=2;
	public static final int DB_MSSQL=3;
	public static final int DB_SYBASE=4;
	public static final String name_DB(int i){
		switch (i) {
		case DB_ORACLE:return "oracle";
		case DB_MYSQL:return "mysql";
		case DB_DB2:return "db2";
		case DB_MSSQL:return "mssqlserver";
		case DB_SYBASE:return "sybasesqlserver";
		default:
			return "unknown";
		}
	}
	
	public static final String REPORT_DOWNLOAD_FILE_SUFFIX="reportDownLoadFileSuffix";
	public static final String REPORT_DOWNLOAD_FILE_TYPE="reportDownLoadFileType";
	public static final String INNER_REPORT_DOWNLOAD_BEGIN_ROW="innerReportDownLoadBeginRow";
	
	public static final String PAGE_INDEX="PAGE_INDEX";
	public static final String PAGE_COUNT="PAGE_COUNT";
	public static final String RULE_TYPE="REPORT_RULE_TYPE";
	
	public static final String EXTERNAL_SERVICE_SELECTMODE_ACS="1";
	public static final String EXTERNAL_SERVICE_SELECTMODE_SOFA="2";
	public static final String EXTERNAL_SERVICE_SELECTMODE_ALL="3";
	public static final String EXTERNAL_SERVICE_SELECTMODE_SCHEDULE="4";
	
	public static final String name_EXTERNAL_SERVICE_SELECTMODE(String i) {
		if (EXTERNAL_SERVICE_SELECTMODE_ACS.equals(i)) {
			return "接口实现";
		} else if (EXTERNAL_SERVICE_SELECTMODE_SOFA.equals(i)) {
			return "sofa常量配置实现";
		} else if (EXTERNAL_SERVICE_SELECTMODE_ALL.equals(i)) {
			return "批量导出，内部判断实现接口或者使用默认外部地址";
		} else if (EXTERNAL_SERVICE_SELECTMODE_SCHEDULE.equals(i)) {
			return "自动任务调度实现";
		}
		return "";
	}
	
	public static final String EXTERNAL_SERVICE_PROTOCOL_FTP="1";
	public static final String EXTERNAL_SERVICE_PROTOCOL_SFTP="2";
	
	public static final String EXTERNAL_SERVICE_CREATE_EMPTY_FILE="whether_create_empty_file";
	
	
	public static final String EXTERNAL_SERVICE_SELECTMODE="configMode";
	public static final String EXTERNAL_SERVICE_SELECTMODE_ADDRESS="configAddress";
}
